<?php
/**
 * 描述：杂志期刊-期刊列表。
 * @final
 */
final class Exec_Magazine_Ejournal_List extends Exec
{
    /**
     * 描述：期刊列表。
     * @access public
     */
    public function Get()
    {
        #获取数据-最新一期
        $data=DB::GetRows('select * from ejournal order by ID asc limit 0,1');
        if($data){
            $data=$data[0];
        }
        View::Assign('Ejournal_List_Topside',$data);

        #获取数据-期刊列表
        if($data){
            $data=DB::GetData('select * from ejournal where ID<>'.$data['ID'].' order by ID desc limit ?,20');
        }
        else{
            $data=NULL;
        }
        View::Assign('Ejournal_List_Ejournal',@$data['Record']);
        
        #渲染输出               
        View::Assign('Ejournal_List_PageMenu',PagerFactory::Create('Common')->Fetch($data,array
        (
            'URL'=>'/exec.php?action=magazine_ejournal_list',
            'IsDetail'=>TRUE,
            'Rewriter'=>new PagerRewrite('/ejournal/','type','html')
        )));
        View::Display('magazine/ejournal/list.tpl');
    }

    /**
     * 描述：期刊订阅。
     * @access public
     */
    public function Post()
    {
        #获取数据
        $data=array
        (
            'CompanyName'=>Functions::FormArgs('CompanyName',200,TRUE),
            'Linkman'=>Functions::FormArgs('Linkman',200,TRUE),
            'PhoneNumber'=>Functions::FormArgs('PhoneNumber',200,TRUE),
            'Email'=>Functions::FormArgs('Email',200,TRUE)
        );

        #插入数据
        DB::Insert('ejournal_subscription',$data);
        echo 'Success';
    }
}
?>